const isWeixin=function(){
    let ua = window.navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        return true;
    } else {
        return false;
    }
}
const tovueurl = (url) =>{
    var allpath=window.location.href
    var hashpath=window.location.hash
    var pos=allpath.indexOf(hashpath);
    var rooturl=allpath.substring(0,pos)
    if(rooturl.indexOf('/?')>0){
        rooturl = rooturl.substring(0,rooturl.indexOf('?'))
    }
    return rooturl+url
}
const hasSid=function(){
    if(isWeixin()){
        let sid=sessionStorage.getItem('sid')
        if(!sid){
            var wxloginurl=encodeURIComponent(tovueurl('#/login'))
            var gotourl=`http://u.mysun365.com/UserCenter/chat/simpleAcsAuth.jsp?sysType=ADCARD&logValue=wd192xd129&gotoUrl=`+wxloginurl+`&scope=snsapi_base`
            location.href=gotourl
        }
    }else{
        return false
    }
}
export {hasSid}